package com.xiaozhichao.javaapi.base.thread;

import org.junit.Test;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * 线程池测试
 */
public class ThreadPoolTest {

    @Test
    public void threadPoolExceptionTest(){
        ExecutorService pool = Executors.newFixedThreadPool(2);
        Runnable runCommon = new Runnable() {
            @Override
            public void run() {
                for(int i=0;i<1000;i++){
                    System.out.println(i);
                }
            }
        };
        Runnable runException = new Runnable() {
            @Override
            public void run() {
                try{
                    Integer.parseInt("er");
                }catch (Exception e){
                    System.out.println(e);
                }
            }
        };
        pool.execute(runCommon);
        pool.execute(runException);
    }

}
